package com.longrise.android.byjk.plugins.tabthird.personal;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/6.
 * 更换背景高级版的viewpager adapter
 */

public class ChangeSeniorPagerAdapter extends FragmentPagerAdapter {


    private List<BackGroundWallBean> mParentList = new ArrayList<>();

    public ChangeSeniorPagerAdapter(FragmentManager supportFragmentManager) {
        super(supportFragmentManager);

    }

    public void setData(List<BackGroundWallBean> parentList) {
        mParentList.clear();
        mParentList.addAll(parentList);
        this.notifyDataSetChanged();
    }


    @Override
    public Fragment getItem(int position) {
        ChangeSeniorWallDeatilFragment fragment = new ChangeSeniorWallDeatilFragment();
        Bundle bundle = new Bundle();
        bundle.putString(ChangeSeniorWallDeatilFragment.BACKGROUNDID,mParentList.get(position).getId());
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getCount() {
        return mParentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        BackGroundWallBean allCourseParentBean = mParentList.get(position);
        String assortmentname = allCourseParentBean.getAreaname();
        return assortmentname;
    }

    @Override
    public void finishUpdate(ViewGroup container) {
        try{
            super.finishUpdate(container);
        } catch (NullPointerException nullPointerException){
        }
    }
}
